import { defineStore } from 'pinia'
import { ref } from 'vue'

export const gameStateStore = defineStore(
  'game',
  () => {
    const gameState = ref(false)
    const changeState = () => {
      gameState.value = !gameState.value
    }
    const countDown = ref(0)
    const changeCountDownState = (val) => {
      countDown.value = val
    }
    const isPaused = ref(0)
    const changePaused = (val) => {
      isPaused.value = val
    }
    const scoreAndMessage = ref('快开始游戏吧')
    const changeScoreAndMessage = (val) => {
      scoreAndMessage.value = val
    }
    const finalScore = ref(0)
    const changeFinalScore = (val) => {
      finalScore.value = val
    }
    const highestScore = ref(0)
    const changeHighestScore = (val) => {
      highestScore.value = val
    }
    const speed = ref(1)
    const changeSpeed = (val) => {
      speed.value = val
    }
    const stopMusicModelChange = ref(false)
    const changeStopMusicModelChange = (val) => {
      stopMusicModelChange.value = val
    }
    return {
      gameState,
      changeState,
      countDown,
      changeCountDownState,
      isPaused,
      changePaused,
      scoreAndMessage,
      changeScoreAndMessage,
      finalScore,
      changeFinalScore,
      highestScore,
      changeHighestScore,
      speed,
      changeSpeed,
      stopMusicModelChange,
      changeStopMusicModelChange,
    }
  },
  {
    persist: true,
  },
)
